Updating a Database Using Flash MX Professional 2004
Table of Contents
Update Packets in Detail
An update packet is an XML document that describes the contents of a DeltaPacket. The RDBMSResolver component's update packet contains enough information to be able to construct SQL statements that mirror the operations that were performed to the data in the DataSet. The following snippet shows a sample update packet.
<update_packet tableName="customers" nullValue="{_NULL_}" transID="46386292065">
<delete id="11295627477">
<field name="id" type="numeric" oldValue="10" key="true"/>
</delete>
<insert id="12345678901">
<field name="id" type="numeric" newValue="20" key="true"/>
<field name="FName" type="string" newValue="Davey" key="false"/>
<field name="LName" type="string" newValue="Jones" key="false"/>
</insert>
<update id="98765432101">
<field name="id" type="numeric" oldValue="30" newValue="40" key="true"/>
<field name="FName" type="string" oldValue="Peter" newValue="Mickey" key="false"/>
<field name="LName" type="string" oldValue="Tork" newValue="Dolenz" key="false"/>
</update>
</update_packet>
Every update packet contains the <update_packet> node
as the top level node. This node holds information such as the name
of the table to be updated, a string that is used to signal null field
values, and the transaction ID for this update packet. The tableName and nullValue attributes
are used when parsing the packet into SQL statements and come from
properties on the resolver. The transID value is created
by the DataSet component and should be returned to the resolver in
the result packet.
Below the top level node are the operation nodes: <insert>, <delete>,
or <update>. These nodes are unlimited in number
and can be in any order. Each operation node has an id attribute that
the DataSet component uses to uniquely identify the operation.
Each operation node contains child nodes that list fields for the
purpose of either giving key field information to locate the correct
record, or for setting a new value for that field. The following table
lists the attributes that can be on a <field> node.
| Attribute | Description |
|---|---|
name |
Name of the field. |
type |
Data type of the field. |
key |
True if the field is a key field; False otherwise. |
oldValue |
Original value of the field when obtained from the table. This attribute does not exist for insert operations. |
newValue |
Most recent value set for the field within the DataSet component. This attribute only exists if the field value has been changed. |
Since the <field> node can have both old and new
values, a single node can simultaneously identify a key field and update
that field's value. For example:
<field name="id" type="numeric" oldValue="30" newValue="40" key="true"/>